package com.cosina.game.colorball;

import java.util.Random;

import com.cosina.game.R;
import com.cosina.game.R.drawable;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

public class BallView {
	public static final int GREEN = 0;
	public static final int BLUE = 1;
	public static final int RED = 2;
	public static final int YELLOW = 3;
	public static final int PURPLE = 4;
	
	public static final int size = 22;
	
	private static final Random random = new Random();
	
	public static int getRandomColor(int difficulty){
		return random.nextInt(difficulty);
	}
	
	public static final Bitmap[] pics = new Bitmap[5];
	
	public static void init(Context context){
		loadBallView(BLUE, R.drawable.blue,context);
		loadBallView(RED, R.drawable.red,context);
    	loadBallView(GREEN, R.drawable.green,context);
    	loadBallView(YELLOW, R.drawable.yellow,context);
    	loadBallView(PURPLE, R.drawable.purple,context);
	}
	
    private static void loadBallView(int color, int resId,Context context) {
		Drawable ballPic = context.getResources().getDrawable(resId);
        Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
       
        Canvas canvas = new Canvas(bitmap);
        ballPic.setBounds(0, 0, size, size);
        ballPic.draw(canvas);
        
        pics[color] = bitmap;
    }
}
